-
Notifications
You must be signed in to change notification settings - Fork 11
Update the API to support pypixelbuf 2.0 #15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm pretty sure that both of those pylint complaints will go away with the changes to pypixelbuf. |
@@ -95,7 +104,10 @@ def __init__( | |||
if not pixel_order: | |||
pixel_order = GRB if bpp == 3 else GRBW | |||
else: | |||
bpp = len(pixel_order) | |||
if isinstance(pixel_order, tuple): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if it's a string instead of a tuple?
Strings are currently used in this library, but I'm not sure what the current desire is for pixel_order
? tuple? string? both?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I should have left that line outside of the tuple check. That way when pixel_order
is supplied we always use its length as bpp
. Then we check if it is a tuple, if yes, it gets converted to a string. And if it is already a string it is good to go as is.
This fixes the problem you were seeing for RBGW as well.
See code comment. Works for RGB but breaks for RGBW. It's failing to set import time
import board
import neopixel_spi as neopixel
NUM_PIXELS = 12
PIXEL_ORDER = neopixel.GRBW
COLORS = (0xFF0000, 0x00FF00, 0x0000FF)
DELAY = 0.1
pixels = neopixel.NeoPixel_SPI(board.SPI(), NUM_PIXELS, pixel_order=PIXEL_ORDER)
while True:
for color in COLORS:
for i in range(NUM_PIXELS):
pixels[i] = color
pixels.show()
time.sleep(DELAY)
pixels.fill(0) Adafruit CircuitPython 5.1.0 on 2020-04-02; Adafruit ItsyBitsy M4 Express with samd51g19
>>> import test
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "test.py", line 15, in <module>
File "/lib/neopixel_spi.py", line 147, in _transmit
File "/lib/neopixel_spi.py", line 163, in _transmogrify
IndexError: bytearray index out of range
>>> |
47a3357
to
c953ef3
Compare
Yep. That seems to have fixed it. |
Ok great! I'm going to merge now because the lint errors are based on the old version of pypixelbuf that is released. |
Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel to 6.0.0 from 5.1.1: > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#83 from adafruit/tannewt-patch-1 > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel#82 from dunkmann00/pixelbuf Updating https://github.com/adafruit/Adafruit_CircuitPython_NeoPixel_SPI to 0.8.0 from 0.4.1: > Merge pull request adafruit/Adafruit_CircuitPython_NeoPixel_SPI#15 from dunkmann00/pypixelbuf-2.0-compat Updating https://github.com/adafruit/Adafruit_CircuitPython_AzureIoT to 2.0.0 from 1.1.0: > Merge pull request adafruit/Adafruit_CircuitPython_AzureIoT#11 from jimbobbennett/master > build.yml: add black formatting check Updating https://github.com/adafruit/Adafruit_CircuitPython_Pypixelbuf to 2.0.0 from 1.0.3: > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#19 from dunkmann00/dotstar_brightness > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#18 from dunkmann00/_pixelbuf_cp > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#17 from adafruit/black-update > build.yml: add black formatting check > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#16 from kattni/update-example-name > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#12 from adafruit/pylint-update > update code of coduct: discord moderation contact section > Merge pull request adafruit/Adafruit_CircuitPython_Pypixelbuf#11 from sommersoft/patch_coc > update pylintrc for black
Voila! #14